package src.twice;

import javax.swing.*;
import java.io.File;

public class FileDeletionFrame extends JFrame {

    protected void deleteFile(File root, JTextArea textArea){
        if(root.isFile()){
            root.delete();
            textArea.append(root.getAbsolutePath());
        }else {
            File[] files = root.listFiles();
            for (File file : files) {
                if(file.isFile()){
                    file.delete();
                    textArea.append(file.getAbsolutePath()+"\n\r");
                }else {
                    deleteFile(file,textArea);
                }
            }
        }
        root.delete();
    }
}
